using System;
using System.ComponentModel;
using System.Threading;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Interfaces;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Respondents;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.OperationContracts
{
    public partial class InventoryServiceClient
    {

        #region GetProductCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Product>> GetProductCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetProductCollection(bool isShowAll, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetProductCollection(isShowAll, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Product> IInventoryService.EndGetProductCollection(IAsyncResult result)
        {
            return Channel.EndGetProductCollection(result);
        }

        private IAsyncResult OnBeginGetProductCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            bool isShowAll = (bool)inValues[0];

            return ((IInventoryService)(this)).BeginGetProductCollection(isShowAll, callback, asyncState);
        }

        private object[] OnEndGetProductCollection(IAsyncResult result)
        {
            CollectionFeedback<Product> retVal = ((IInventoryService)(this)).EndGetProductCollection(result);
            return new object[] { retVal };
        }

        private void OnGetProductCollectionCompleted(object state)
        {
            if ((GetProductCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetProductCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<Product>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetProductCollectionAsync(bool isShowAll)
        {
            GetProductCollectionAsync(isShowAll, null);
        }

        public void GetProductCollectionAsync(bool isShowAll, object userState)
        {
            if ((onBeginGetProductCollectionDelegate == null))
            {
                onBeginGetProductCollectionDelegate = new BeginOperationDelegate(OnBeginGetProductCollection);
            }
            if ((onEndGetProductCollectionDelegate == null))
            {
                onEndGetProductCollectionDelegate = new EndOperationDelegate(OnEndGetProductCollection);
            }
            if ((onGetProductCollectionCompletedDelegate == null))
            {
                onGetProductCollectionCompletedDelegate = new SendOrPostCallback(OnGetProductCollectionCompleted);
            }
            InvokeAsync(onBeginGetProductCollectionDelegate, new object[] {
                    isShowAll}, onEndGetProductCollectionDelegate, onGetProductCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetProductCollectionDelegate;

        private EndOperationDelegate onEndGetProductCollectionDelegate;

        private SendOrPostCallback onGetProductCollectionCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetProductCollection(bool isShowAll, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = isShowAll;

                IAsyncResult _result = BeginInvoke("GetProductCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Product> EndGetProductCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Product> _result = ((CollectionFeedback<Product>)(EndInvoke("GetProductCollection", _args, result)));
                return _result;
            }
        }

        #endregion

        #region GetProductCollectionType

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Product>> GetProductCollectionTypeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetProductCollectionType(bool isShowAll, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetProductCollectionType(isShowAll, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Product> IInventoryService.EndGetProductCollectionType(IAsyncResult result)
        {
            return Channel.EndGetProductCollectionType(result);
        }

        private IAsyncResult OnBeginGetProductCollectionType(object[] inValues, AsyncCallback callback, object asyncState)
        {
            bool isShowAll = (bool)inValues[0];

            return ((IInventoryService)(this)).BeginGetProductCollectionType(isShowAll, callback, asyncState);
        }

        private object[] OnEndGetProductCollectionType(IAsyncResult result)
        {
            CollectionFeedback<Product> retVal = ((IInventoryService)(this)).EndGetProductCollectionType(result);
            return new object[] { retVal };
        }

        private void OnGetProductCollectionTypeCompleted(object state)
        {
            if ((GetProductCollectionTypeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetProductCollectionTypeCompleted(this, new CollectionFeedbackCompletedEventArgs<Product>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetProductCollectionTypeAsync(bool isShowAll)
        {
            GetProductCollectionTypeAsync(isShowAll, null);
        }

        public void GetProductCollectionTypeAsync(bool isShowAll, object userState)
        {
            if ((onBeginGetProductCollectionTypeDelegate == null))
            {
                onBeginGetProductCollectionTypeDelegate = new BeginOperationDelegate(OnBeginGetProductCollectionType);
            }
            if ((onEndGetProductCollectionTypeDelegate == null))
            {
                onEndGetProductCollectionTypeDelegate = new EndOperationDelegate(OnEndGetProductCollectionType);
            }
            if ((onGetProductCollectionTypeCompletedDelegate == null))
            {
                onGetProductCollectionTypeCompletedDelegate = new SendOrPostCallback(OnGetProductCollectionTypeCompleted);
            }
            InvokeAsync(onBeginGetProductCollectionTypeDelegate, new object[] {
                    isShowAll}, onEndGetProductCollectionTypeDelegate, onGetProductCollectionTypeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetProductCollectionTypeDelegate;

        private EndOperationDelegate onEndGetProductCollectionTypeDelegate;

        private SendOrPostCallback onGetProductCollectionTypeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetProductCollectionType(bool isShowAll, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = isShowAll;

                IAsyncResult _result = BeginInvoke("GetProductCollectionType", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Product> EndGetProductCollectionType(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Product> _result = ((CollectionFeedback<Product>)(EndInvoke("GetProductCollectionType", _args, result)));
                return _result;
            }
        }

        #endregion
       
        #region GetSingleProduct

        public event EventHandler<SingleFeedbackCompletedEventArgs<Product>> GetSingleProductCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetSingleProduct(int productID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetSingleProduct(productID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<Product> IInventoryService.EndGetSingleProduct(IAsyncResult result)
        {
            return Channel.EndGetSingleProduct(result);
        }

        private IAsyncResult OnBeginGetSingleProduct(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int productID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginGetSingleProduct(productID, callback, asyncState);
        }

        private object[] OnEndGetSingleProduct(IAsyncResult result)
        {
            SingleFeedback<Product> retVal = ((IInventoryService)(this)).EndGetSingleProduct(result);
            return new object[] { retVal };
        }

        private void OnGetSingleProductCompleted(object state)
        {
            if ((GetSingleProductCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetSingleProductCompleted(this, new SingleFeedbackCompletedEventArgs<Product>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleProductAsync(int productID)
        {
            GetSingleProductAsync(productID, null);
        }

        public void GetSingleProductAsync(int productID, object userState)
        {
            if ((onBeginGetSingleProductDelegate == null))
            {
                onBeginGetSingleProductDelegate = new BeginOperationDelegate(OnBeginGetSingleProduct);
            }
            if ((onEndGetSingleProductDelegate == null))
            {
                onEndGetSingleProductDelegate = new EndOperationDelegate(OnEndGetSingleProduct);
            }
            if ((onGetSingleProductCompletedDelegate == null))
            {
                onGetSingleProductCompletedDelegate = new SendOrPostCallback(OnGetSingleProductCompleted);
            }
            InvokeAsync(onBeginGetSingleProductDelegate, new object[] {
                                                                                  productID}, onEndGetSingleProductDelegate, onGetSingleProductCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleProductDelegate;

        private EndOperationDelegate onEndGetSingleProductDelegate;

        private SendOrPostCallback onGetSingleProductCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetSingleProduct(int productID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = productID;

                IAsyncResult _result = BeginInvoke("GetSingleProduct", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<Product> EndGetSingleProduct(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<Product> _result = ((SingleFeedback<Product>)(EndInvoke("GetSingleProduct", _args, result)));
                return _result;
            }
        }

        #endregion

        #region InsertProduct

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertProductCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginInsertProduct(Product data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginInsertProduct(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<int> IInventoryService.EndInsertProduct(IAsyncResult result)
        {
            return Channel.EndInsertProduct(result);
        }

        private IAsyncResult OnBeginInsertProduct(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Product data = (Product)inValues[0];

            return ((IInventoryService)(this)).BeginInsertProduct(data, callback, asyncState);
        }

        private object[] OnEndInsertProduct(IAsyncResult result)
        {
            SingleFeedback<int> retVal = ((IInventoryService)(this)).EndInsertProduct(result);
            return new object[] { retVal };
        }

        private void OnInsertProductCompleted(object state)
        {
            if ((InsertProductCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                InsertProductCompleted(this, new SingleFeedbackCompletedEventArgs<int>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InsertProductAsync(Product data)
        {
            InsertProductAsync(data, null);
        }

        public void InsertProductAsync(Product data, object userState)
        {
            if ((onBeginInsertProductDelegate == null))
            {
                onBeginInsertProductDelegate = new BeginOperationDelegate(OnBeginInsertProduct);
            }
            if ((onEndInsertProductDelegate == null))
            {
                onEndInsertProductDelegate = new EndOperationDelegate(OnEndInsertProduct);
            }
            if ((onInsertProductCompletedDelegate == null))
            {
                onInsertProductCompletedDelegate = new SendOrPostCallback(OnInsertProductCompleted);
            }
            InvokeAsync(onBeginInsertProductDelegate, new object[] {
                                                                               data}, onEndInsertProductDelegate, onInsertProductCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginInsertProductDelegate;

        private EndOperationDelegate onEndInsertProductDelegate;

        private SendOrPostCallback onInsertProductCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginInsertProduct(Product data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("InsertProduct", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<int> EndInsertProduct(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<int> _result = ((SingleFeedback<int>)(EndInvoke("InsertProduct", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region InsertBuiltupMaterial

        public event EventHandler<FeedbackCompletedEventArgs> InsertBuiltupMaterialCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginInsertBuiltupMaterial(int pID, int mID, long mQuantity, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginInsertBuiltupMaterial(pID, mID, mQuantity, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndInsertBuiltupMaterial(IAsyncResult result)
        {
            return Channel.EndInsertBuiltupMaterial(result);
        }

        private IAsyncResult OnBeginInsertBuiltupMaterial(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int pID = (int)inValues[0];
            int mID = (int)inValues[1];
            long mQuantity = (long)inValues[2];

            return ((IInventoryService)(this)).BeginInsertBuiltupMaterial(pID, mID, mQuantity, callback, asyncState);
        }

        private object[] OnEndInsertBuiltupMaterial(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndInsertBuiltupMaterial(result);
            return new object[] { retVal };
        }

        private void OnInsertBuiltupMaterialCompleted(object state)
        {
            if ((InsertBuiltupMaterialCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                InsertBuiltupMaterialCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InsertBuiltupMaterialAsync(int pID, int mID, long mQuantity)
        {
            InsertBuiltupMaterialAsync(pID, mID, mQuantity, null);
        }

        public void InsertBuiltupMaterialAsync(int pID, int mID, long mQuantity, object userState)
        {
            if ((onBeginInsertBuiltupMaterialDelegate == null))
            {
                onBeginInsertBuiltupMaterialDelegate = new BeginOperationDelegate(OnBeginInsertBuiltupMaterial);
            }
            if ((onEndInsertBuiltupMaterialDelegate == null))
            {
                onEndInsertBuiltupMaterialDelegate = new EndOperationDelegate(OnEndInsertBuiltupMaterial);
            }
            if ((onInsertBuiltupMaterialCompletedDelegate == null))
            {
                onInsertBuiltupMaterialCompletedDelegate = new SendOrPostCallback(OnInsertBuiltupMaterialCompleted);
            }
            InvokeAsync(onBeginInsertBuiltupMaterialDelegate, new object[] {
                    pID, mID, mQuantity}, onEndInsertBuiltupMaterialDelegate, onInsertBuiltupMaterialCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginInsertBuiltupMaterialDelegate;

        private EndOperationDelegate onEndInsertBuiltupMaterialDelegate;

        private SendOrPostCallback onInsertBuiltupMaterialCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginInsertBuiltupMaterial(int pID, int mID, long mQuantity, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[3];
                _args[0] = pID;
                _args[1] = mID;
                _args[2] = mQuantity;

                IAsyncResult _result = BeginInvoke("InsertBuiltupMaterial", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndInsertBuiltupMaterial(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("InsertBuiltupMaterial", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region UpdateProduct

        public event EventHandler<FeedbackCompletedEventArgs> UpdateProductCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUpdateProduct(Product data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUpdateProduct(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUpdateProduct(IAsyncResult result)
        {
            return Channel.EndUpdateProduct(result);
        }

        private IAsyncResult OnBeginUpdateProduct(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Product data = (Product)inValues[0];

            return ((IInventoryService)(this)).BeginUpdateProduct(data, callback, asyncState);
        }

        private object[] OnEndUpdateProduct(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUpdateProduct(result);
            return new object[] { retVal };
        }

        private void OnUpdateProductCompleted(object state)
        {
            if ((UpdateProductCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UpdateProductCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UpdateProductAsync(Product data)
        {
            UpdateProductAsync(data, null);
        }

        public void UpdateProductAsync(Product data, object userState)
        {
            if ((onBeginUpdateProductDelegate == null))
            {
                onBeginUpdateProductDelegate = new BeginOperationDelegate(OnBeginUpdateProduct);
            }
            if ((onEndUpdateProductDelegate == null))
            {
                onEndUpdateProductDelegate = new EndOperationDelegate(OnEndUpdateProduct);
            }
            if ((onUpdateProductCompletedDelegate == null))
            {
                onUpdateProductCompletedDelegate = new SendOrPostCallback(OnUpdateProductCompleted);
            }
            InvokeAsync(onBeginUpdateProductDelegate, new object[] {
                                                                               data}, onEndUpdateProductDelegate, onUpdateProductCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUpdateProductDelegate;

        private EndOperationDelegate onEndUpdateProductDelegate;

        private SendOrPostCallback onUpdateProductCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUpdateProduct(Product data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("UpdateProduct", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUpdateProduct(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UpdateProduct", _args, result)));
                return _result;
            }
        }

        #endregion

        #region DeleteProduct

        public event EventHandler<FeedbackCompletedEventArgs> DeleteProductCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginDeleteProduct(int data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginDeleteProduct(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndDeleteProduct(IAsyncResult result)
        {
            return Channel.EndDeleteProduct(result);
        }

        private IAsyncResult OnBeginDeleteProduct(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int data = (int)inValues[0];

            return ((IInventoryService)(this)).BeginDeleteProduct(data, callback, asyncState);
        }

        private object[] OnEndDeleteProduct(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndDeleteProduct(result);
            return new object[] { retVal };
        }

        private void OnDeleteProductCompleted(object state)
        {
            if ((DeleteProductCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                DeleteProductCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void DeleteProductAsync(int data)
        {
            DeleteProductAsync(data, null);
        }

        public void DeleteProductAsync(int data, object userState)
        {
            if ((onBeginDeleteProductDelegate == null))
            {
                onBeginDeleteProductDelegate = new BeginOperationDelegate(OnBeginDeleteProduct);
            }
            if ((onEndDeleteProductDelegate == null))
            {
                onEndDeleteProductDelegate = new EndOperationDelegate(OnEndDeleteProduct);
            }
            if ((onDeleteProductCompletedDelegate == null))
            {
                onDeleteProductCompletedDelegate = new SendOrPostCallback(OnDeleteProductCompleted);
            }
            InvokeAsync(onBeginDeleteProductDelegate, new object[] {
                                                                               data}, onEndDeleteProductDelegate, onDeleteProductCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginDeleteProductDelegate;

        private EndOperationDelegate onEndDeleteProductDelegate;

        private SendOrPostCallback onDeleteProductCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginDeleteProduct(int data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("DeleteProduct", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndDeleteProduct(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("DeleteProduct", _args, result)));
                return _result;
            }
        }

        #endregion

        #region DeleteProductBuiltup

        public event EventHandler<FeedbackCompletedEventArgs> DeleteProductBuiltupCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginDeleteProductBuiltup(int pID, int mID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginDeleteProductBuiltup(pID, mID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndDeleteProductBuiltup(IAsyncResult result)
        {
            return Channel.EndDeleteProductBuiltup(result);
        }

        private IAsyncResult OnBeginDeleteProductBuiltup(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int pID = (int)inValues[0];
            int mID = (int)inValues[1];

            return ((IInventoryService)(this)).BeginDeleteProductBuiltup(pID, mID, callback, asyncState);
        }

        private object[] OnEndDeleteProductBuiltup(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndDeleteProductBuiltup(result);
            return new object[] { retVal };
        }

        private void OnDeleteProductBuiltupCompleted(object state)
        {
            if ((DeleteProductBuiltupCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                DeleteProductBuiltupCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void DeleteProductBuiltupAsync(int pID, int mID)
        {
            DeleteProductBuiltupAsync(pID, mID, null);
        }

        public void DeleteProductBuiltupAsync(int pID, int mID, object userState)
        {
            if ((onBeginDeleteProductBuiltupDelegate == null))
            {
                onBeginDeleteProductBuiltupDelegate = new BeginOperationDelegate(OnBeginDeleteProductBuiltup);
            }
            if ((onEndDeleteProductBuiltupDelegate == null))
            {
                onEndDeleteProductBuiltupDelegate = new EndOperationDelegate(OnEndDeleteProductBuiltup);
            }
            if ((onDeleteProductBuiltupCompletedDelegate == null))
            {
                onDeleteProductBuiltupCompletedDelegate = new SendOrPostCallback(OnDeleteProductBuiltupCompleted);
            }
            InvokeAsync(onBeginDeleteProductBuiltupDelegate, new object[] {
                    pID, mID}, onEndDeleteProductBuiltupDelegate, onDeleteProductBuiltupCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginDeleteProductBuiltupDelegate;

        private EndOperationDelegate onEndDeleteProductBuiltupDelegate;

        private SendOrPostCallback onDeleteProductBuiltupCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginDeleteProductBuiltup(int pID, int mID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[2];
                _args[0] = pID;
                _args[1] = mID;

                IAsyncResult _result = BeginInvoke("DeleteProductBuiltup", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndDeleteProductBuiltup(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("DeleteProductBuiltup", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region SearchProduct

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Product>> SearchProductCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginSearchProduct(ProductCriteria criteria, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginSearchProduct(criteria, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Product> IInventoryService.EndSearchProduct(IAsyncResult result)
        {
            return Channel.EndSearchProduct(result);
        }

        private IAsyncResult OnBeginSearchProduct(object[] inValues, AsyncCallback callback, object asyncState)
        {
            ProductCriteria criteria = (ProductCriteria)inValues[0];

            return ((IInventoryService)(this)).BeginSearchProduct(criteria, callback, asyncState);
        }

        private object[] OnEndSearchProduct(IAsyncResult result)
        {
            CollectionFeedback<Product> retVal = ((IInventoryService)(this)).EndSearchProduct(result);
            return new object[] { retVal };
        }

        private void OnSearchProductCompleted(object state)
        {
            if ((SearchProductCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                SearchProductCompleted(this, new CollectionFeedbackCompletedEventArgs<Product>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void SearchProductAsync(ProductCriteria criteria)
        {
            SearchProductAsync(criteria, null);
        }

        public void SearchProductAsync(ProductCriteria criteria, object userState)
        {
            if ((onBeginSearchProductDelegate == null))
            {
                onBeginSearchProductDelegate = new BeginOperationDelegate(OnBeginSearchProduct);
            }
            if ((onEndSearchProductDelegate == null))
            {
                onEndSearchProductDelegate = new EndOperationDelegate(OnEndSearchProduct);
            }
            if ((onSearchProductCompletedDelegate == null))
            {
                onSearchProductCompletedDelegate = new SendOrPostCallback(OnSearchProductCompleted);
            }
            InvokeAsync(onBeginSearchProductDelegate, new object[] {
                                                                               criteria}, onEndSearchProductDelegate, onSearchProductCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginSearchProductDelegate;

        private EndOperationDelegate onEndSearchProductDelegate;

        private SendOrPostCallback onSearchProductCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginSearchProduct(ProductCriteria criteria, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = criteria;

                IAsyncResult _result = BeginInvoke("SearchProduct", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Product> EndSearchProduct(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Product> _result = ((CollectionFeedback<Product>)(EndInvoke("SearchProduct", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UndoDeleteProduct

        public event EventHandler<FeedbackCompletedEventArgs> UndoDeleteProductCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUndoDeleteProduct(int objID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUndoDeleteProduct(objID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUndoDeleteProduct(IAsyncResult result)
        {
            return Channel.EndUndoDeleteProduct(result);
        }

        private IAsyncResult OnBeginUndoDeleteProduct(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int objID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginUndoDeleteProduct(objID, callback, asyncState);
        }

        private object[] OnEndUndoDeleteProduct(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUndoDeleteProduct(result);
            return new object[] { retVal };
        }

        private void OnUndoDeleteProductCompleted(object state)
        {
            if ((UndoDeleteProductCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UndoDeleteProductCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UndoDeleteProductAsync(int objID)
        {
            UndoDeleteProductAsync(objID, null);
        }

        public void UndoDeleteProductAsync(int objID, object userState)
        {
            if ((onBeginUndoDeleteProductDelegate == null))
            {
                onBeginUndoDeleteProductDelegate = new BeginOperationDelegate(OnBeginUndoDeleteProduct);
            }
            if ((onEndUndoDeleteProductDelegate == null))
            {
                onEndUndoDeleteProductDelegate = new EndOperationDelegate(OnEndUndoDeleteProduct);
            }
            if ((onUndoDeleteProductCompletedDelegate == null))
            {
                onUndoDeleteProductCompletedDelegate = new SendOrPostCallback(OnUndoDeleteProductCompleted);
            }
            InvokeAsync(onBeginUndoDeleteProductDelegate, new object[] {
                    objID}, onEndUndoDeleteProductDelegate, onUndoDeleteProductCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUndoDeleteProductDelegate;

        private EndOperationDelegate onEndUndoDeleteProductDelegate;

        private SendOrPostCallback onUndoDeleteProductCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUndoDeleteProduct(int objID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = objID;

                IAsyncResult _result = BeginInvoke("UndoDeleteProduct", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUndoDeleteProduct(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UndoDeleteProduct", _args, result)));
                return _result;
            }
        }

        #endregion
        

    }
}